package com.gdwstudy.GenericExer;

import java.util.Comparator;

/**
 * @author 关道伟
 * @version 1.0
 */
public class Mydate implements Comparable<Mydate> {
    private int year;
    private int month;
    private int day;

    public Mydate(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    @Override
    public String toString() {
        return "Mydate{" +
                "year=" + year +
                ", month=" + month +
                ", day=" + day +
                '}';
    }


    @Override
    public int compareTo(Mydate o) {
        if(year != o.getYear()){
            return year-o.getYear();
        }
        if(month!=o.getMonth()){
            return month-o.getMonth();
        }
        return day-o.getDay();
    }
}
